with System;
with Win32;
with Win32.Winnt;
with Win32.Winbase;

package win32api_interface is
  subtype Address is System.Address;
  subtype Handle is Win32.Winnt.HANDLE;

  Win32_Error : exception;
  function Get_Last_Error return Win32.DWORD renames Win32.Winbase.GetLastError;

  procedure Report_Error(Operation : String);
  -- Raises Win32_Error with an appropriate error message after a failed
  -- Win32 operation. Do not use under threading contexts.

  procedure Report_Error_Thr(Operation : in String; Error_ID : in Win32.DWORD);
  -- For use under threading contexts, call with Get_Last_Error as the Error_ID
  -- parameter. See http://www.adacore.com/wp-content/files/auto_update/
  -- gnat-unw-docs/html/gnat_ugn_35.html why.
private
  function Get_Error_Message(Error_ID : in Win32.DWORD) return string;

  procedure Put_Error(Operation : in String; Error_ID : in Win32.DWORD);
  pragma No_Return(Put_Error);
end win32api_interface;
